<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1">
    <caption>个人信息</caption>
    <tr>
        <td>照片:</td><td><img src="" alt=""></td>
    </tr>
    <tr>
        <td>姓名:</td><td id="name_td"></td>
    </tr>
    <tr>
        <td>年龄:</td><td id="age_td"></td>
    </tr>
    <tr>
        <td>好友:</td>
        <td><ul></ul></td>
    </tr>
</table>
<input type="button" value="请求数据" onclick="f()">
<script>
    function f() {
        //模拟从服务器请求到的数据
        let p = {name:"苍老师",url:"a.jpg",age:"20",
            friends:["传奇哥","克晶姐","老干妈"]}
        //把对象中的数据展示到页面中
        name_td.innerText = p.name;
        age_td.innerText = p.age;
        //得到图片标签
        let img = document.querySelector("img");
        img.src = p.url;
        //得到ul
        let ul = document.querySelector("ul");
        //遍历好友
        for (let friend of p.friends) {
            //创建li
            let li = document.createElement("li");
            li.innerText = friend;
            //把li添加到ul里面
            ul.append(li);
        }


    }
</script>
</body>
</html>